#!/bin/bash

date +%Y-%m-%d > instances_info.txt
aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" --query 'Reservations[*].{InstanceType:Instances[0].InstanceType,Name:Instances[0].Tags[0].Value}' --output table >> instances_info.txt

#if [ -z $1 ]; then
date +%Y-%m-%d>aws_info.txt
#aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" --query 'Reservations[*].{InstanceId:Instances[0].InstanceId,InstanceType:Instances[0].InstanceType}' --output text
echo "ec2num  ec2type" >> aws_info.txt
aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" --query 'Reservations[*].{InstanceType:Instances[0].InstanceType}' --output text | sort |uniq -c |sort -nr >> aws_info.txt

#exit 0
#fi

#type=$1

#aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" "Name=instance-type,Values=${type}" --query 'Reservations[*].{InstanceId:Instances[0].InstanceId,InstanceType:Instances[0].InstanceType}'
